class Solution {
public:
string explain(const string& s)
	{
		//使用双指针算法
		int left = 0;
		int right = 0;
		string ret;
		while(right <= s.size())
		{
			if(right == s.size())
			{
				ret += to_string(right -left);
				ret += s[left];
				return ret;
			}
			if(s[left] == s[right])
			{
				right++;
			}
			else 
			{
				ret += to_string(right - left);
				ret += s[left];
				left = right;
			}
		}
        return "0";
	}
    string countAndSay(int n) 
    {
    	if(n == 1)
    	{
    		return "1";
    	}
    	string ans;
    	ans += "1";
        for(int i = 2; i <= n; i++)
        {
        	ans = explain(ans);
        }
        return ans;
    }
};